package com.fingard.dsp.bank.reqrespobj.billpool;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.billpool.Detail.RetAtsB321QryFinancingApplyDetail;
import com.fingard.xml.XmlTextWriter;

public class RetAtsB321QryFinancingApply extends RetAtsBase {
    public String respCode;
    public String respInfo;
    public String transState;
    public String reqSeqID;
    public String payInfoCode;
    public String batchState;

    public RetAtsB321QryFinancingApply(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();
    }

    public void writeRetDetail(RetAtsB321QryFinancingApplyDetail p_retDetail) throws Exception {
        retXmlWriter.writeStartElement("DetailRecord");
        retXmlWriter.writeElementString("BillNo", p_retDetail.billNo);
        retXmlWriter.writeElementString("BillType", p_retDetail.billType);
        retXmlWriter.writeElementString("IssDate", p_retDetail.issDate);
        retXmlWriter.writeElementString("DueDate", p_retDetail.dueDate);
        retXmlWriter.writeElementString("BillAmt", p_retDetail.billAmt);
        retXmlWriter.writeElementString("DrawName", p_retDetail.drawName);
        retXmlWriter.writeElementString("DrawAct", p_retDetail.drawAct);
        retXmlWriter.writeElementString("DrawBnkName", p_retDetail.drawBnkName);
        retXmlWriter.writeElementString("DrawBnkCode", p_retDetail.drawBnkCode);
        retXmlWriter.writeElementString("AccpName", p_retDetail.accpName);
        retXmlWriter.writeElementString("AccpAct", p_retDetail.accpAct);
        retXmlWriter.writeElementString("AccpBnkName", p_retDetail.accpBnkName);
        retXmlWriter.writeElementString("AccpBnkCode", p_retDetail.accpBnkCode);
        retXmlWriter.writeElementString("PayeeName", p_retDetail.payeeName);
        retXmlWriter.writeElementString("PayeeAct", p_retDetail.payeeAct);
        retXmlWriter.writeElementString("PayeeBnkName", p_retDetail.payeeBnkName);
        retXmlWriter.writeElementString("PayeeBnkCode", p_retDetail.payeeBnkCode);
        retXmlWriter.writeElementString("TransFlag", p_retDetail.transFlag);
        retXmlWriter.writeElementString("BillStatus", p_retDetail.billStatus);
        retXmlWriter.writeEndElement();
    }

    private boolean hasWrittenBefore = false;

    public void writeBeforeDetail() throws Exception {
        if (hasWrittenBefore) {
            throw new Exception("writeBeforeDetail已被调用过");
        }
        writeStart();
        retXmlWriter.writeElementString("ReqSeqID", reqSeqID);
        retXmlWriter.writeElementString("RespCode", respCode);
        retXmlWriter.writeElementString("RespInfo", respInfo);
        retXmlWriter.writeElementString("TransState", transState);
        retXmlWriter.writeElementString("PayInfoCode", payInfoCode);
        retXmlWriter.writeElementString("BatchState",this.batchState);
        hasWrittenBefore = true;
    }

    public void writeAfterDetail() throws Exception {
        if (!hasWrittenBefore) {
            writeBeforeDetail();
        }
        writeEnd();// 写结束
    }
}
